$(function () {
    toastr.warning("请上传JPG或者PNG格式的图片")
    setTimeout(function () {
        toastr.warning("请确保酒店存在房型照片对应")
    },3000)
    /*先隐藏*/
    $("#menu1").hide();$("#menu2").hide();$("#menu3").hide();$("#menu4").hide();
    /*再根据hotelRoomType 部分显示*/
    $.each(JSON.parse(hotelRoomType),function (index,value) {
        var num=value;
        var newMenu='#menu'+num;
        console.info("num:"+num+"---newMenu:"+newMenu);
        $(newMenu).show();
       /*$("#menu"+num).show();*/
    })
    if(big.indexOf("jpg") == -1 && big.indexOf("png") == -1){
        $("#id1").hide();
    }
    if(dou.indexOf("jpg")== -1 && dou.indexOf("png") == -1){
        $("#id2").hide();
    }
    if(cir.indexOf("jpg")== -1 && cir.indexOf("png")== -1){
        $("#id3").hide();
    }
    if(cou.indexOf("jpg")== -1 && cou.indexOf("png")==-1){
        $("#id4").hide();
    }

    $("#mainPic").attr("src","/img/picImg?url="+mainPicLocation)
    $("#bigPic").attr("src","/img/picImg?url="+big)
    $("#douPic").attr("src","/img/picImg?url="+dou)
    $("#cirPic").attr("src","/img/picImg?url="+cir)
    $("#couPic").attr("src","/img/picImg?url="+cou)

    
    $('#btn-uploadPhoto').click(function () {
        var formData = new FormData($("#yanzheng")[0]);  //重点：要用这种方法接收表单的参数
        formData.append("mainPicLocation",mainPicLocation);
        formData.append("big",big);
        formData.append("dou",dou);
        formData.append("cir",cir);
        formData.append("cou",cou);
       /* var data=$('#yanzheng').serialize();
        var resultJson={};
        resultJson.mainPicLocation=mainPicLocation;
        resultJson.big=big;
        resultJson.dou = dou;
        resultJson.cir = cir;
        resultJson.cou = cou;
        resultJson.hotelId=hotelId;
        resultJson.NewmainPic=$('#main').val();
        console.info("图片更新信息:"+resultJson)*/
        $.ajax({
            url:ctx+"businessHigh/uploadPhotoEdit",
            type:"post",
            dataType:"json",
            data: formData ,
            /*async: false,  //同步请求*/
            cache: false, //上传文件无需缓存
            contentType: false, //用于对data参数进行序列化处理 这里必须false
            processData: false,
            success:function (data) {
                console.info("酒店图片操作状态:"+data.msg);
                toastr.success(data.msg)
                setTimeout(function () {
                    /*window.location.reload();*/
                    window.location.href=ctx+"business/uploadInfoEdit"
                },1500)
            },
            error:function (data) {
                toastr.error(data.msg)
            }
        })
    })
})